package com.edu.jvm.unit01.Dynamic.assign;

/**
 * 方法静态分派演示
 *
 * @author five-five
 * @created 2021/10/9-18:47
 */
public class StaticDispatch {
    static abstract class Human {
    }

    static class Woman extends Human {
    }

    static class Man extends Human {
    }

    public void sayHello(Human human) {
        System.out.println("hello,guy!");
    }

    public void sayHello(Man man) {
        System.out.println("hello,Man!");
    }

    public void sayHello(Woman woman) {
        System.out.println("hello,woman!");
    }

    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();
        Man mancast = new Man();
        Woman womancast = new Woman();
        StaticDispatch staticDispatch = new StaticDispatch();
        staticDispatch.sayHello(man);
        staticDispatch.sayHello(woman);
        staticDispatch.sayHello(womancast);
        staticDispatch.sayHello(mancast);
    }

}
